<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /*
      之前:
      创建对象 --- 构造函数 ---- new 构造函数()

      ES6之后(包括):
      类(class) -- 对构造函数的封装
    */

    class Person {
      // 构造器(构造函数)
      constructor(name, age) {
        this.name = name
        this.age = age
      }

      say() {
        console.log(this.name + '在说话')
      }
    }

    const p1 = new Person('张三', 18)
    console.log(p1)
    p1.say()

    const p2 = new Person('李四', 20)
    console.log(p2)
    p2.say()

    console.log(p1.say === p2.say)
  </script>
</body>

</html>